#ifndef __4E703FC9_3C92_48a1_B1DA_B9712FD184A4__
#define __4E703FC9_3C92_48a1_B1DA_B9712FD184A4__

#include "../import/head.h"
#include "../tools/head.h"

//////////////////////////////////////////////////////////////////////////////////
// 

namespace xos_sgsj
{
    class data;
    class tcp;
    class udp;

	class session : public xos_stl::mem_pool_item< session, thread_lock >
    {
    public:
        typedef xos_stl::auto_ref< session > ref;

        enum enumType
        {
            TYPE_TCP_LISTEN,
            TYPE_TCP_DATA,
            TYPE_UDP
        };

    public:
        session();
        ~session();

    public:
        xos_encrypt::i_encrypt * m_pEncrypt;
        xos::i_queue * m_pQueue;
        enumType m_eType;

        xos::xos_i64 m_tLastHeartTimestampS;
        int net_timeout_s;

		bool m_bNeedClose;
		bool m_bQuiting;

        bool m_bTimeout;
        int m_nRefCount;
        
        tcp * m_pTcp;
        udp * m_pUdp;

    public:
        int init_add_ref( int nAddNum );
        int add_ref( int nAddNum );
        int sub_ref( int nSubNum );

        int post_send( data * pData );
        int post_close();

    public:
		int release();
        int init();
        int term();
    };
} // xos_sgsj

#endif // __4E703FC9_3C92_48a1_B1DA_B9712FD184A4__
